package cn.znzz.cjm.quartz.job;

import cn.znzz.cjm.order.service.IAdoptOrderService;
import cn.znzz.cjm.quartz.constant.JobTypeConstants;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

public class MainJob implements Job{
    @Autowired
    private IAdoptOrderService adoptOrderService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        Map<String ,Object> map=(Map<String ,Object>)jobDataMap.get("params");
        String type = (String)map.get("type");

        switch (type){
            case JobTypeConstants.TIME_OUT_ADOPT_LAST_PAY:{
                //领养订单的支付超时
                Long orderId = (Long)jobDataMap.get("orderId");
                adoptOrderService.cancelByQuartz(orderId);
                break;
            }
            default:break;
        }
    }
}
